#include "webengineview.h"
#include <QPalette>
#include <QAbstractItemView>
WebEngineView::WebEngineView()
{
    isNewWindow=false;
    Label_Error=new QLabel;
    Label_Error->setText("Error");
    Label_Error->setParent(this);
    Label_Error->move(0,0);
    Label_Error->show();
    Label_Error->raise();
//    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
//    QPalette::ColorRole plt();
//    plt.setColor(QPalette::Background,QColor(0,0,0));
//    setBackgroundRole(QPalette::Window);
//    set

}

WebEngineView::~WebEngineView()
{
    delete Label_Error;
}


WebEngineView *WebEngineView::createWindow(QWebEnginePage::WebWindowType type)
{
    Q_UNUSED(type)
    p=new WebEngineView;
    connect(p,&QWebEngineView::urlChanged,[=](QUrl url) {
        onUrlChanged(url,type);
    });
//    emit newWindow(p);
    return p;
}

void WebEngineView::onUrlChanged(QUrl url, int type)
{

    isNewWindow=true;
    newWindowType=type;
    disconnect(p, nullptr, nullptr, nullptr);
    emit urlChanged(url);
}
